import Vue from "vue";
import VueRouter, { RouteConfig } from "vue-router";
import Home from "../Home.vue";
import Search from "../Search.vue";
import Detail from "../Detail.vue";

Vue.use(VueRouter);

const routes: Array<RouteConfig> = [
  {
    path: "/",
    component: Search,
  },
  {
    path: "/l/:word",
    name: "Home",
    component: Home,
  },
  {
    path: "/d/:id",
    name: "Detail",
    component: Detail,
  },
];

const router = new VueRouter({
  routes,
});

router.afterEach(() => {
  window.scrollTo(0, 0);
});

export default router;
